let app = getApp();
var applet_park_api_url = app.globalData.applet_park_api_url;
const {
  requestDataparams
} = require('../../../utils/request.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    showModalData: false,
    show: false,
    showoperationArea: false,
    wateraccount:'256333',
    electricaccount:'256444',
    propertyaccount:'256555',
    inputUnit:1//单元
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {

  },
  showModalD(){
    this.setData({
      showModalData: true,
      showoperationArea: true
    })
  },
  hideModalD(){
    this.setData({
      showModalData: false,
      showoperationArea: false
    })
  },
  enteraddCount(){//新增缴费
    this.setData({
      show: true,
      showoperationArea: false
    })
  },
  enteraccountManagement(){//户号管理
    wx.navigateTo({
      url: '../accountManagement/accountManagement',
    })
  },
  enterpaymentRecord(){//缴费记录
    wx.navigateTo({
      url: '../paymentRecord/paymentRecord',
    })
  },
  enterAddCount(e){
      var type = e.currentTarget.dataset.type;
      wx.navigateTo({
        url: '../addCount/addCount?type='+type,
      })
  },
  
   submitForWater(e){
    var value =e.currentTarget.dataset.account;
     requestDataparams('/api/unifiedOrder/queryWaterRateInfo/value',{}, 'POST','json').then(response=>{
                  
                   if(response.data.code == 0){
                     var datas = response.data.data;
                     var accountName = datas.accountName;
                     var accountNumber = value;
                     var address = datas.address;
                     var totalMoney = datas.totalMoney;
                     var unit = datas.unit;
                     wx.navigateTo({
                         url: '../chargeForWater/chargeForWater?accountName='+accountName+'&accountNumber='+accountNumber+'&address='+address+'&totalMoney='+totalMoney+'&unit='+unit,
                       })
                    
                   }else{
                     wx.showToast({
                       title: '失败',
                       icon:'none'
                     })
                   }
           })
   },
   submitForElectric(e){
    var value =e.currentTarget.dataset.account;
    requestDataparams('/api/unifiedOrder/queryPowerRateInfo/value',{}, 'POST','json').then(response=>{
                 
                  if(response.data.code == 0){
                   var datas = response.data.data;
                   var accountName = datas.accountName;
                   var accountNumber = value;
                   var address = datas.address;
                   var totalMoney = datas.totalMoney;
                   var unit = datas.unit;
                   wx.navigateTo({
                     url: '../chargeForElectric/chargeForElectric?accountName='+accountName+'&accountNumber='+accountNumber+'&address='+address+'&totalMoney='+totalMoney+'&unit='+unit,
                   })
                   
                  }else{
                    wx.showToast({
                      title: '失败',
                      icon:'none'
                    })
                  }
          })
   },
   submitForProperty(e){
     var value =e.currentTarget.dataset.account;
    requestDataparams('/api/unifiedOrder/queryPropertyFeeInfo',{}, 'POST','json').then(response=>{
                 
                  if(response.data.code == 0){
                   var datas = response.data.data;
                   var buildAddress = datas.buildAddress;
                   var accountNumber = value;
                   var totalMoney = datas.totalMoney;
                   var unit = this.data.inputUnit;
                   wx.navigateTo({
                     url: '../chargeForProperty/chargeForProperty?buildAddress='+buildAddress+'&totalMoney='+totalMoney+'&unit='+unit+'&accountNumber='+accountNumber,
                   })
                   
                  }else{
                    wx.showToast({
                      title: '失败',
                      icon:'none'
                    })
                  }
          })
   },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
    this.setData({
      showModalData: false,
      show: false,
      showoperationArea: false,
     })
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
       
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})